< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03020411.xhp

(section: mkdir) (bookmark: bm_id3156421)
MkDir statement

MkDir ステートメント

MkDir Statement [Runtime]
MkDir ステートメント [実行時](hd_id3156421.1)

Creates a new directory on a data medium.
データ記録媒体上に新規ディレクトリを作成します。(par_id3147000.2)

(/section: mkdir)

Syntax:
構文:(hd_id3148520.3)

MkDir Text As String
MkDir Text As String(par_id3155150.4)

Parameters:
パラメータ:(hd_id3156027.5)

Text: Any string expression that specifies the name and path of the directory to be created. You can also use URL notation.
Text: 作成するディレクトリの名前およびパスを指定する文字列表式。またURL 指定を用いることもできます。(par_id3153750.6)

If the path is not determined, the directory is created in the current directory.
有効なパスが指定されなかった場合、現在のディレクトリの中に新規ディレクトリが作成されます。(par_id3153311.7)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

(embed text/sbasic/shared/00000003.xhp#err76 : linkinfo)

76 Path not found
76 パスが見つかりません (par_id3150477.75)

(/embed text/sbasic/shared/00000003.xhp#err76)

Example:
例:(hd_id3155388.8)

Sub ExampleFileIO
Sub ExampleFileIO(par_id3148473.9)

' Example for functions of the file organization
' ファイルを整理するための機能の例(par_id3149762.10)

Const sFile1 as String = "file://c|/autoexec.bat"
Const sFile1 as String = "file://c|/autoexec.bat"(par_id3145610.11)

Const sDir1 as String = "file://c|/Temp"
Const sDir1 as String = "file://c|/Temp"(par_id3147264.12)

Const sSubDir1 as String ="Test"
Const sSubDir1 as String ="Test"(par_id3149669.13)

Const sFile2 as String = "Copied.tmp"
Const sFile2 as String = "Copied.tmp"(par_id3148663.14)

Const sFile3 as String = "Renamed.tmp"
Const sFile3 as String = "Renamed.tmp"(par_id3154071.15)

Dim sFile as String
Dim sFile as String(par_id3150792.16)

sFile = sDir1 + "/" + sSubDir1
SFile = sDir1 + "/" + sSubDir1(par_id3154366.17)

ChDir( sDir1 )
ChDir( sDir1 )(par_id3149204.18)

If Dir(sSubDir1,16)="" then ' Does the directory exist ?
If Dir(sSubDir1,16)="" then ' ディレクトリが存在するかの確認(par_id3154217.19)

MkDir sSubDir1
MkDir sSubDir1(par_id3156423.20)

MsgBox sFile,0,"Create directory"
MsgBox sFile,0,"Create directory"(par_id3147228.21)

End If
End If(par_id3153970.22)

sFile = sFile + "/" + sFile2
SFile = sFile + "/" + sFile2(par_id3148451.24)

FileCopy sFile1 , sFile
FileCopy sFile1 , sFile(par_id3155132.25)

MsgBox fSysURL(CurDir()),0,"Current directory"
MsgBox fSysURL(CurDir()),0,"Current directory"(par_id3153770.26)

MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Creation time"
MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Creation time"(par_id3159154.27)

MsgBox sFile & Chr(13)& FileLen( sFile ),0,"File length"
MsgBox sFile & Chr(13)& FileLen( sFile ),0,"ファイルサイズ"(par_id3149484.28)

MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"File attributes"
MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"ファイル属性"(par_id3152885.29)

Name sFile as sDir1 + "/" + sSubDir1 + "/" + sFile3
Name sFile as sDir1 + "/" + sSubDir1 + "/" + sFile3(par_id3152596.30)

' Rename in the same directory
' 同一ディレクトリ内で名前を変更(par_id3153952.31)

sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3
sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3(par_id3152576.33)

SetAttr( sFile, 0 ) 'Delete all attributes
SetAttr( sFile, 0 ) 'すべての属性の削除(par_id3147426.34)

MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"New file attributes"
MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"New file attributes"(par_id3148647.35)

Kill sFile
Kill sFile(par_id3153363.36)

RmDir sDir1 + "/" + sSubDir1
RmDir sDir1 + "/" + sSubDir1(par_id3151113.37)

end sub
end sub(par_id3153157.38)

' Converts a system path in URL
' システムパスを URL に変換(par_id3150092.40)

Function fSysURL( fSysFp as String ) as String
Function fSysURL( fSysFp as String ) as String(par_id3147396.41)

Dim iPos As String
Dim iPos As String(par_id3153878.42)

iPos = 1
IPos = 1(par_id3150420.43)

iPos = Instr(iPos,fSysFp, getPathSeparator())
IPos = Instr(iPos,fSysFp, getPathSeparator())(par_id3145253.44)

do while iPos > 0
do while iPos > 0(par_id3153415.45)

mid( fSysFp, iPos , 1,"/")
mid( fSysFp, iPos , 1,"/")(par_id3153512.46)

iPos = Instr(iPos+1,fSysFp, getPathSeparator())
iPos = Instr(iPos+1,fSysFp, getPathSeparator())(par_id3146899.47)

loop
Loop(par_id3145652.48)

' the colon with DOS
' DOS のコロン処理(par_id3156276.49)

iPos = Instr(1,fSysFp,":")
iPos = Instr(1,fSysFp,":")(par_id3146913.50)

if iPos > 0 then mid( fSysFp, iPos , 1,"|")
if iPos > 0 then mid( fSysFp, iPos , 1,"|")(par_id3145640.51)

fSysURL = "file://" & fSysFp
fSysURL = "file://" & fSysFp(par_id3155443.52)

End Function
End Function(par_id3148995.53)


< Prev / Next >